#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<string.h>
int main()
{
	int t = 0;
	scanf("%d", &t);
	getchar();
	while (t--)
	{
		char arr[85] = { 0 };
		gets(arr);
		int sz = strlen(arr);
		
		for (int i = 0; i < sz; i++)
		{
			if (*(arr + i) != ' ' && *(arr + i) != '\0' && *(arr + i) < 'a')
			{
				*(arr + i) += 32;
			}
		}
		//printf("%s", arr);
		char* end = arr;
		char* str = arr;
		int count = 0;

		while(*str)
		{
			count = 0;
			while ((*end) != ' ' && (*end) != '\0')
			{
				end++;
				count++;
			}
			if (count > 4)
			{
				for (int i = 0; i < 4; i++)
				{
					printf("%c", *(str + i));
				}
				if (*end != '\0')
				{
					printf(". ");
				}
				else
				{
					printf(".");
				}
			}
			else
			{
				for (int i = 0; i < count; i++)
				{
					printf("%c", *(str + i));
				}
				if (*end != '\0')
				{
					printf(" ");
				}
			}
				if ((*end) == ' ')
				{
					str = end + 1;
					end++;
				}
				else
				{
					str = end;
				}
			
		}
		printf("\n");
	}
	return 0;
}